// pages/Home/schoolCam/schoolCam.js
var businessLogic = require('../../../utils/NetWork/Model/HomebusinessLogic.js')
var common = require('../../../utils/common.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    content:[],
    num:1,
    scrollHeight: 0,
  },
  camDetail: function (event) {
    //跳转
    wx.navigateTo({
      url: "../camDetail/camDetail?id=" + event.currentTarget.dataset.classid
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var orgid = common.getStorageSync("orgid")
    var userid = common.getStorageSync("userid")
    var scrollHeight = scrollHeight;
    wx.getSystemInfo({
      success: function (res) {
        scrollHeight = res.windowHeight
      }
    });
    this.setData({
      orgid: orgid,
      userid: userid,
      scrollHeight: scrollHeight,
    });
    this.schoolCam()
  },
  bindDownLoad: function () {
    if(this.data.lenpage>this.data.num){
    var di = this.data.num;
    var di = di + 1;
    this.setData({
      num: di
    });
    this.schoolCam();
    }else{
      common.showToast("到底了", "loading");
    }
    //common.showToast("到底了", "loading");

  },
  scroll: function (event) {
    //该方法绑定了页面滚动时的事件，我这里记录了当前的position.y的值,为了请求数据之后把页面定位到这里来。

  },
  topLoad: function (event) {
    //  该方法绑定了页面滑动到顶部的事件，然后做上拉刷新
  }, 
  schoolCam: function () {
    common.showLoading("加载中", "loading");
    let params = { "page": this.data.num, "num": 15, "orgid": this.data.orgid, "userid": this.data.userid }
    businessLogic.SchoolHonoraryxiao(params, (res) => {
      var bbb=this.data.content;
      for (var a = 0; a < res.infos.length; a++) {
        bbb.push(res.infos[a]);
      }
     // console.log(res.page.pages)
      this.setData({
        content: bbb,
        lenpage:res.page.pages
      });
      common.hideLoading();
    });

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
   
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})